package java_thinking.unit_18_IO._18_6;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringReader;

/**
 * @Desc:   使用PrintWriter中的辅助构造器就无需每次创建文件时去执行所有的装饰工作，下面是BasicFileOutput重写后的结果
 * @author: cww
 * @DateTime: 2019/5/14 19:51
 */

public class FileOutPutShortcut {
    static String file = "src/maindemo/java/java_thinking/unit_18_IO/_18_6/FileOutPutShortcut.txt";

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new StringReader(BufferedInputFile.read("src/maindemo/java/java_thinking/unit_18_IO/_18_6/FileOutPutShortcut.java")));
        PrintWriter out = new PrintWriter(file);
        int lineCount = 1;
        String s;
        while ((s = in.readLine()) != null) {
            out.println(lineCount++ + ": " + s);
        }
        out.close();
        System.out.println(BufferedInputFile.read(file));
    }
}
